package juc.entities;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Arrays;
import java.util.List;

/**
 * @author Guo
 * @Create 2020/9/2 8:53
 */
@AllArgsConstructor
@Data
@NoArgsConstructor
public class User {
    private Integer id;
    private String userName;
    private int age;

}

/**
 * 题目:请按照给出数据,找出同时满足以下条件的用户，也即以下条件全部满足
 *      偶数ID,年龄大于24 用户名转为大写 且用户名字母倒序
 *      只输出一个用户名字
        */
class StreamDemo {
    public static void main(String[] args) {
        User u1 = new User(11, "a", 23);
        User u2 = new User(12, "b", 24);
        User u3 = new User(13, "c", 22);
        User u4 = new User(14, "d", 28);
        User u5 = new User(16, "e", 26);

        List<User> list = Arrays.asList(u1, u2, u3, u4, u5);

        list.stream().filter(t -> {
            return t.getId() % 2 == 0;
        }).filter(t -> {
            return t.getAge() > 24;
        }).map(t -> {
            return t.getUserName().toUpperCase();
        }).sorted((o1,o2) -> {
            return o2.compareTo(o1);
        }).limit(1).forEach(System.out::println);














//        Function<String,Integer> function = new Function<String, Integer>() {
//            public Integer apply(String s) {
//                return 1024;
//            }
//        };
//        System.out.println(function.apply("abc"));

//        Function<String,Integer> function = s -> {return s.length();};
//        System.out.println(function.apply("abc"));

//        Predicate<String> predicate = new Predicate<String>() {
//            @Override
//            public boolean test(String s) {
//                return false;
//            }
//        };

//        Predicate<String> predicate = s -> {return s.isEmpty();};
//        System.out.println(predicate.test("xiaos"));


//        Consumer<String> consumer = new Consumer<String>() {
//            @Override
//            public void accept(String s) {
//
//            }
//        };
//        Consumer<String> consumer = s -> { System.out.println(s); };
//        consumer.accept("xiaosi");

//        Supplier<String> supplier = new Supplier<String>() {
//            @Override
//            public String get() {
//                return null;
//            }
//        };
//        Supplier<String> supplier = () -> {return "java022";};
//        System.out.println(supplier.get());
    }
}

interface MyInterface {
    public int myInt(int x);

    public boolean isOk(String str);
}